/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yinsh
 * Date: 2025-01-12
 * Time: 12:22
 */
public class Computer {
    public void powerOff(){
        System.out.println("打开电脑");
    }
    public void powerOn(){
        System.out.println("关闭电脑");
    }
   public void useService(IUSB u){//以接口引用类型接受发生向上转型
       IUSB usb = u;
        if(usb instanceof Mouse){
            usb.setService();//多态
            ((Mouse)usb).click();//向下转型
            usb.closeService();//多态
        }
        if(usb instanceof keyBoard){
            usb.setService();//多态
            ((keyBoard)usb).print();//向下转型
            usb.closeService();//多态
        }
   }
}
